package com.begye.smartloan.apptest.sezhi

import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.begye.smartloan.apptest.MyApplication
import com.begye.smartloan.apptest.R
import com.begye.smartloan.apptest.databinding.AtSeZhiBinding
import com.begye.smartloan.apptest.kefu.KeFuDialogFragment
import com.begye.smartloan.apptest.signinup.ui.SignInUpActivity
import com.begye.smartloan.apptest.tool.addTouch
import com.util.utillib.extend.IntentFlagMode
import com.util.utillib.extend.toNextActivity


@SuppressLint("CustomWelcomeScreen")
class SeZhiActivity : AppCompatActivity() {

    private lateinit var _binding: AtSeZhiBinding

    @SuppressLint("NotifyDataSetChanged")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()

        _binding = AtSeZhiBinding.inflate(layoutInflater)
        setContentView(_binding.root)

        configUIEvent()
    }

    private fun configUIEvent() {

        _binding.atSeZhiNar.initConfig(
            text = getString(R.string.se_zhi_text_4),
            textColor = "#000000",
            leftResId = R.drawable.dres_39,
            rightResId = R.drawable.dres_38
        ) {
            if (0 == it) {
                finish()
            } else if (1 == it) {
                val dialog = KeFuDialogFragment()
                dialog.showNow(supportFragmentManager, "kefu")
            }
        }

        _binding.atSeZhiLogout.setOnClickListener {
            toNextActivity(
                activity = SignInUpActivity::class.java,
                mode = IntentFlagMode.SINGLE_TOP
            )
        }

        _binding.atSeZhiVersion.text =
            getString(R.string.se_zhi_text_1, MyApplication.appVersion.toString())
    }


    override fun onResume() {
        super.onResume()

        addTouch(type = this.javaClass.simpleName, isOpen = true)
    }

    override fun onPause() {
        super.onPause()

        addTouch(type = this.javaClass.simpleName, isComplete = true)
    }
}

